package com.news.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.news.entity.User;
import com.news.service.UserService;


@WebServlet("/adminupdatepwd")
public class AdminUpdatePwdServlet extends HttpServlet {

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String password1 = request.getParameter("password1");
		
		UserService uService = new UserService();
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		uService.updataPwd(user);
		if(password.equals(password1)){
			boolean flag = uService.updataPwd(user);
			response.sendRedirect(request.getContextPath()+"/jsp/admineditpassword.jsp");
		}else{
			System.out.println("error");
		}
	}

}
